
package cc.ufinity.networkdiagnose.adapter;


import cc.ufinity.networkdiagnose.view.R;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


public class GridAdapter extends BaseAdapter{
	
	private Activity ctx;
	private int[] icons;
	private String[] texts;
	
	private LayoutInflater mInflater;
	
	public GridAdapter(Activity ctx, int[] icons, String[] texts){
		this.ctx = ctx;
		this.icons = icons;
		this.texts = texts;
		mInflater = LayoutInflater.from(ctx);
	}

	@Override
	public int getCount() {
		return texts.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.item_imageview, null);
		TextView text = (TextView)convertView.findViewById(R.id.text);
		text.setTextColor(Color.WHITE);
		text.setText(texts[position]);
		Drawable draw = ctx.getResources().getDrawable(icons[position]);
		draw.setBounds(0, 3, draw.getIntrinsicWidth(), draw.getIntrinsicHeight());
	//	draw.setBounds(0, 3, 45, 45);
		text.setCompoundDrawables(null, draw, null, null);
		
		return convertView;
	}
}
